/** ***********************************************
 * CodeGen
 *
 * @author  Jonnie Spratley
 * @date 3/05/2009
 * @licence MCIYC
 * @website http://jonniespratley.com/code
 * @contact jonniespratley@gmail.com
 *********************************************** */
package com.jonniespratley.codegen.vo
{
	import mx.collections.ArrayCollection;


	[Bindable]
	public class PHPResultsVO
	{
		public var methodCalled:String;
		public var methodResults:ArrayCollection

		public function PHPResultsVO( obj:Object = null )
		{
			if ( obj != null )
			{
				this.methodCalled = obj['methodCalled'];
				
				if ( obj['methodResults'] != null )
				{
					//set the fields comming back as an Array
					var tempArray:Array = obj['methodResults'] as Array;
					var tempAc:ArrayCollection = new ArrayCollection();
					
					for( var str:String in tempArray )
					{
						var object:Object = { label: str };
						tempAc.addItem( object );
					}
					

					//create a temp arraycollection so return to the aFields
					this.methodResults = tempAc;
				}
			}
		}

		public function get label():String
		{
			return this.methodCalled;
		}

		public function get children():Array
		{
			return this.methodResults.toArray();
		}
	}
}